// pages/2411Ayiliao-pages/physical/detail.js
Page({
  data:{
    detail:null,
    loading:false
  },
  onLoad(options){
    const id = options.id
    if(!id){ wx.showToast({title:'参数缺失',icon:'none'}); return }
    this.loadDetail(id)
  },
  loadDetail(id){
    this.setData({loading:true});
    wx.showLoading({title:'加载中...'});
    wx.request({
      url:`http://localhost:8084/physical/detail/${id}`,
      method:'GET',
      header:{'Content-Type':'application/json'},
      success:(res)=>{
        wx.hideLoading(); this.setData({loading:false});
        let body=res.data; if(typeof body==='string'){try{body=JSON.parse(body)}catch(e){body=null}}
        if(body && body.code!==undefined){ if(body.code!==200){wx.showToast({title:body.message||'请求失败',icon:'none'});return} body=body.data }
        this.setData({detail:body||{}})
      },
      fail:()=>{
        wx.hideLoading(); this.setData({loading:false});
        this.setData({detail:{
          id,
          hospital:'北京市第一人民医院·东院区',
          address:'北京市大兴区**路990号',
          reportPlace:'门诊三楼分诊台',
          package:'男性体检基础A套餐',
          reportDate:'2020-12-30',
          queue:'现场取号',
          amount:'1200.00',
          appointDate:'2020-12-12',
          patient:'牛韦',
          idCard:'610*********0989'
        }})
      }
    })
  }
}) 